#include "playbackwidget.h"

#include <QMessageBox>
#include <QComboBox>
#include <QDebug>
#include <QMouseEvent>
#include <QTimer>
#include <QDateTime>

#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>
#include <QJsonValue>



PlaybackWidget::PlaybackWidget(QWidget *parent) : QWidget(parent)
{

    //禁止父窗口影响子窗口样式,必须加上，否则样式不会起作用
    setAttribute(Qt::WA_StyledBackground);

    setSearchUI(); // 搜索界面
    setPlaybackUI(); // 播放界面

    // 主布局
    QVBoxLayout *mainLayout = new QVBoxLayout(this);

    mainLayout->addWidget(searchWidget);
    mainLayout->addWidget(progressWidget);
    mainLayout->addWidget(playbackWidget);

    setLayout(mainLayout);

    setConnect();

}

void PlaybackWidget::setSearchUI()
{

    searchWidget = new QWidget(this);
    searchWidget->setFixedHeight(50);

    // 搜索框主布局
    searchLayout = new QHBoxLayout(searchWidget);
    searchLayout->setAlignment(Qt::AlignHCenter);

    // === 日期部分 - 紧凑布局 ===
    QHBoxLayout *dateLayout = new QHBoxLayout(searchWidget);
    dateLayout->setSpacing(5);

    QLabel *dateLabel = new QLabel("日期：", searchWidget);
    dateLabel->setStyleSheet("font-weight: bold; min-width: 40px;");  // 固定标签宽度
    dateLabel->setFixedHeight(25);
    dateEdit = new QDateEdit(QDate::currentDate(), searchWidget);
    dateEdit->setCalendarPopup(true);
    dateEdit->setDisplayFormat("yyyy-MM-dd");
    dateEdit->setFixedSize(150, 25);  // 固定输入框尺寸 [3][7]

    dateLayout->addWidget(dateLabel, 0, Qt::AlignVCenter);  // 垂直居中
    dateLayout->addWidget(dateEdit, 0, Qt::AlignVCenter);


    // === 时间部分实现 ===
    QHBoxLayout *timeLayout = new QHBoxLayout(searchWidget);
    timeLayout->setAlignment(Qt::AlignVCenter);
    timeLayout->setSpacing(20); // 紧凑排列

    QLabel *timeLabel = new QLabel("时间：", searchWidget);
    timeLabel->setStyleSheet("font-weight: bold; min-width: 40px;");

    // === 开始时间选择器 ===
    QWidget *startTimeGroup = new QWidget(searchWidget); // 开始时间容器
    QHBoxLayout *startLayout = new QHBoxLayout(startTimeGroup);
    startLayout->setContentsMargins(0, 0, 0, 0);
    startLayout->setSpacing(10);

    // 小时选择
    startHourBox = new QComboBox(startTimeGroup);
    for(int i = 0; i < 24; i++)
        startHourBox->addItem(QString("%1").arg(i, 2, 10, QChar('0')));
    startHourBox->setCurrentIndex(9); // 默认9点
    startHourBox->setFixedWidth(50); // 固定宽度
    startLayout->addWidget(startHourBox);

    QLabel *startColon = new QLabel(":", startTimeGroup);
    startColon->setFixedWidth(5);
    startLayout->addWidget(startColon);

    // 分钟选择
    startMinuteBox = new QComboBox(startTimeGroup);
    for(int i = 0; i < 60; i++)
        startMinuteBox->addItem(QString("%1").arg(i, 2, 10, QChar('0')));
    startMinuteBox->setFixedWidth(50);
    startLayout->addWidget(startMinuteBox);

    QLabel *startColon2 = new QLabel(":", startTimeGroup);
    startColon2->setFixedWidth(5);
    startLayout->addWidget(startColon2);

    // 秒数选择
    startSecondBox = new QComboBox(startTimeGroup);
    for(int i = 0; i < 60; i++)
        startSecondBox->addItem(QString("%1").arg(i, 2, 10, QChar('0')));
    startSecondBox->setFixedWidth(50);
    startLayout->addWidget(startSecondBox);


    // === 分隔符 ===
    QLabel *toLabel = new QLabel("至", searchWidget);
    toLabel->setFixedWidth(20);


    // === 结束时间选择器 ===

    QWidget *endTimeGroup = new QWidget(searchWidget); // 结束时间容器
    QHBoxLayout *endLayout = new QHBoxLayout(endTimeGroup);
    endLayout->setContentsMargins(0, 0, 0, 0);
    endLayout->setSpacing(10);

    // 小时选择
    endHourBox = new QComboBox(endTimeGroup);
    for(int i = 0; i < 24; i++)
        endHourBox->addItem(QString("%1").arg(i, 2, 10, QChar('0')));
    endHourBox->setCurrentIndex(18); // 默认18点
    endHourBox->setFixedWidth(50);
    endLayout->addWidget(endHourBox);

    QLabel *endColon = new QLabel(":", endTimeGroup);
    endColon->setFixedWidth(5);
    endLayout->addWidget(endColon);

    // 分钟选择
    endMinuteBox = new QComboBox(endTimeGroup);
    for(int i = 0; i < 60; i++)
        endMinuteBox->addItem(QString("%1").arg(i, 2, 10, QChar('0')));
    endMinuteBox->setFixedWidth(50);
    endLayout->addWidget(endMinuteBox);

    QLabel *endColon2 = new QLabel(":", endTimeGroup);
    startColon->setFixedWidth(5);
    endLayout->addWidget(endColon2);

    // 秒数选择
    endSecondBox = new QComboBox(endTimeGroup);
    for(int i = 0; i < 60; i++)
        endSecondBox->addItem(QString("%1").arg(i, 2, 10, QChar('0')));
    endSecondBox->setFixedWidth(50);
    endLayout->addWidget(endSecondBox);

    // 添加到主布局
    timeLayout->addWidget(timeLabel);
    timeLayout->addWidget(startTimeGroup);
    timeLayout->addWidget(toLabel);
    timeLayout->addWidget(endTimeGroup);



    // === 摄像头选择 ===
    QHBoxLayout *deviceLayout = new QHBoxLayout(searchWidget);
    deviceLayout->setContentsMargins(0, 0, 0, 0);
    deviceLayout->setSpacing(10);

    QLabel *deviceLabel = new QLabel("摄像头：", searchWidget);
    deviceLabel->setStyleSheet("font-weight: bold; min-width: 70px;");

    //QWidget *device = new QWidget(searchWidget); // 摄像头容器

    // 摄像头选择
    deviceBox = new QComboBox(searchWidget);
    for(int i = 0; i < 2; i++)
    {
        if(i == 0){
            deviceBox->addItem("摄像头1");
        }else{
            deviceBox->addItem("摄像头2");
        }
    }
    deviceBox->setCurrentIndex(0); // 摄像头1
    deviceBox->setFixedWidth(100); // 固定宽度
    deviceLayout->addWidget(deviceLabel);
    deviceLayout->addWidget(deviceBox);


    // === 通道选择 ===
    QLabel *channelLabel = new QLabel("通道：", searchWidget);
    channelLabel->setStyleSheet("font-weight: bold; min-width: 40px;");

    //QWidget *channel = new QWidget(searchWidget); // 通道容器
    QHBoxLayout *channelLayout = new QHBoxLayout(searchWidget);
    channelLayout->setContentsMargins(0, 0, 0, 0);
    channelLayout->setSpacing(10);

    // 通道选择
    channelBox = new QComboBox(searchWidget);
    for(int i = 0; i < 2; i++)
    {
        if(i == 0){
            channelBox->addItem("通道1");
        }else{
            channelBox->addItem("通道2");
        }
    }
    channelBox->setCurrentIndex(0); // 通道1
    channelBox->setFixedWidth(100); // 固定宽度
    channelLayout->addWidget(channelLabel);
    channelLayout->addWidget(channelBox);


    // === 样式美化 ===

    QString comboStyle = R"(
        QComboBox {
            border: 1px solid #D0D0D0;
            border-radius: 3px;
            padding: 4px 0px;
            selection-background-color: #e6f7ff;
            QAbstractItemView { text-align: center; } // 下拉项居中
            text-align: center;// 输入框文本居中
        }
        QComboBox::drop-down {
            border: none;
            width: 20px;
        }
        QComboBox:hover {
            border: 1px solid #4CAF50;
        }
        QComboBox:on { /* 下拉菜单打开时 */
            background-color: #f0f0f0;
        }
    )";

    // 应用样式
//    startHourBox->setStyleSheet(comboStyle);
//    startMinuteBox->setStyleSheet(comboStyle);
//    //startSecondBox->setStyleSheet(comboStyle);
//    endHourBox->setStyleSheet(comboStyle);
//    endMinuteBox->setStyleSheet(comboStyle);
//    //endSecondBox->setStyleSheet(comboStyle);
    channelBox->setStyleSheet(comboStyle);
    deviceBox->setStyleSheet(comboStyle);


    // === 搜索按钮 ===

    searchButton = new QPushButton("查看录像", searchWidget);
    searchButton->setFixedSize(70, 28);  // 最佳点击尺寸 [3]
    searchButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

    // 实现水平居中
    QHBoxLayout *centerContainer = new QHBoxLayout();
    centerContainer->setSpacing(50);  // 组件间距统一为8px [3]
    centerContainer->addLayout(dateLayout);
    centerContainer->addLayout(timeLayout);
    centerContainer->addLayout(deviceLayout);
    centerContainer->addLayout(channelLayout);
    centerContainer->addWidget(searchButton);
    searchLayout->addLayout(centerContainer);

}

void PlaybackWidget::setPlaybackUI()
{
    playbackWidget = new QWidget(this);

    progressWidget = new QWidget(playbackWidget);
    progressWidget->setFixedHeight(60);

    progressLayout = new QVBoxLayout(progressWidget);
    progressLayout->setContentsMargins(0, 0, 0, 0);

    // 创建进度条
    //progress = new QProgressBar(progressWidget);
    //progress->setRange(0, 86399);           // 对应 24 小时 -1 秒
    //progress->setValue(50000);
    //progress->setTextVisible(false);        // 隐藏默认文本
    //
    // 设置样式：绿色填充 + 浅灰背景 + 圆角边框
    //progress->setStyleSheet(
    //    "QProgressBar {"
    //        "border: 1px solid #C0C0C0;"
    //        "border-radius: 4px;"
    //        "background-color: #E0E0E0;"
    //    "}"
    //    "QProgressBar::chunk {"
    //        "background-color: green;"
    //        "width: 1px;"  /* 每一格代表1秒 */
    //    "}"
    //);

    //progressLayout->addWidget(progress);



    timerangewidget = new TimeRangeWidget(this);

    timerangewidget->setDate(QDate::currentDate());

    // 添加一些示例时间范围
    timerangewidget->addTimeRange(0, 7200); // 00:00 - 02:00
    timerangewidget->addTimeRange(14400, 21600); // 04:00 - 06:00


    progressLayout->addWidget(timerangewidget);

    // 创建小时刻度行
    //QWidget *rulerWidget = new QWidget(progressWidget);
    //QHBoxLayout *rulerLayout = new QHBoxLayout(rulerWidget);
    //rulerLayout->setContentsMargins(0, 0, 0, 0);
    //rulerLayout->setSpacing(0);

    int totalWidth = 800;  // 可根据窗口宽度动态调整
    int labelWidth = totalWidth / 24;

    for (int i = 0; i < 24; ++i) {
        QLabel *label = new QLabel(QString("%1:00").arg(i, 2, 10, QChar('0')));
        label->setFixedWidth(labelWidth);
        label->setAlignment(Qt::AlignCenter);
        label->setStyleSheet("font: 8pt; color: #666666;");
        //rulerLayout->addWidget(label);
    }

    //progressLayout->addWidget(rulerWidget);

//    // 示例：启动定时器模拟播放进度
//    QTimer *timer = new QTimer(this);
//    connect(timer, &QTimer::timeout, [this]() {
//        int val = progress->value();
//        progress->setValue((val + 1) % 86400); // 循环更新
//    });
//    timer->start(100); // 每100ms前进1%



//    playbackList = new PlaybackList(playbackWidget);
//    playbackList->hide();

    playWidget = new PlaybackVideoWidget(playbackWidget);

    playWidget->setStyleSheet("color: black; background-color: rgba(0, 0, 0, 100);");



    playbackProgress = new PlaybackProgress(playbackWidget);

    playbackBottom = new PlaybackBottom(playbackWidget);
    playbackButtonGroup = playbackBottom->getcplaybtn();

    // 布局
    // 列表水平布局
    QHBoxLayout *layout = new QHBoxLayout(playbackWidget);

    // 播放界面与底部栏垂直布局
    QVBoxLayout *playWidgetLayout = new QVBoxLayout(playbackWidget);
    playWidgetLayout->setSpacing(0);

    playWidgetLayout->addWidget(playWidget);
    playWidgetLayout->addWidget(playbackProgress);
    playWidgetLayout->addWidget(playbackBottom);


    layout->addLayout(playWidgetLayout);
    //layout->addWidget(playbackList);





}

void PlaybackWidget::setConnect()
{
    // 信号和槽
    // 搜索
    connect(searchButton, &QPushButton::clicked, this, &PlaybackWidget::onSearchClicked);

    //底部栏
    //播放、暂停
    connect(playbackBottom, &PlaybackBottom::sig_play, this, &PlaybackWidget::onPlayPause);
    //connect(playWidget, &::play_pause, this, &CMainWindow::play_pause);
    //停止
    connect(playbackBottom, &PlaybackBottom::sig_stop, this, &PlaybackWidget::on_btnStop_clicked);
    //全屏缩放
    //connect(playbackBottom, &PlaybackBottom::sig_fullScreen, this, &PlaybackWidget::onFullScreen);

    //时间标签
    //connect(_vlcKits, &VLCKits::sigCurPlay, this, &PlaybackWidget::setCurPlayTime);
    //connect(_vlcKits, &VLCKits::sigTotal, this, &PlaybackWidget::setTotalTime);

    //进度条
    //connect(_vlcKits, &VLCKits::sigTimeSliderPos, this, &CMainWindow::setTimeSliderValue);
    connect(playbackProgress, &QSlider::sliderMoved, this, &PlaybackWidget::onSetPosition);

    //播放列表的显示/隐藏
    //connect(playbackBottom, &PlaybackBottom::sig_list, this, &PlaybackWidget::onShowList);
    //connect(playbackList, &PlaybackList::playbackCurrentItem, this, &PlaybackWidget::onPlaylistItemClicked);

    //connect(_vlcKits, &VLCKits::updateCurrentFileShow, _playlistwidget, &CPlayList::updateCurrentPlayingItem);

    //获得当前播放下标

    //connect(_vlcKits, &VLCKits::updateCurrentFileShow, this, &CMainWindow::setCurrIdx);

    //播放上一个/下一个
//    connect(playbackButtonGroup, &PlaybackPlayButtonGroup::sig_next, this, &PlaybackWidget::onPlayNext);
//    connect(playbackButtonGroup, &PlaybackPlayButtonGroup::sig_pre, this, &PlaybackWidget::onPlayPre);

    //connect(_cVideoWidget, &CVideoWidget::move, this, &PlaybackWidget::videoWidgetMoveEvent);



    connect(timerangewidget, &TimeRangeWidget::timeClicked, this, &PlaybackWidget::onTimeClicked);

    connect(dateEdit , &QDateEdit::dateChanged , timerangewidget , &TimeRangeWidget::setDate);

}




void PlaybackWidget::onTimeClicked(const QDateTime &timestamp)
{
    // 确保参数被使用，消除警告

    // 计算从当天0点开始的秒数
    int seconds = timestamp.time().hour() * 3600 +
            timestamp.time().minute() * 60 +
            timestamp.time().second();

    // 设置当前时间位置
    timerangewidget->setCurrentTime(seconds);

    // 显示点击的时间
    QString message = tr("点击时间: %1");
    //statusBar()->showMessage(message.arg(timestamp.toString("yyyy-MM-dd HH:mm:ss")));

    qDebug() << message.arg(timestamp.toString("yyyy-MM-dd HH:mm:ss"));




    // 打印时间戳（毫秒）
    qDebug() << "Clicked timestamp:" << timestamp.toMSecsSinceEpoch();


    qDebug() << timestamp << camera_id << channel_id;

    qDebug() << timestamp.toMSecsSinceEpoch();

    qDebug() << timestamp.toString().toLongLong();


    playWidget->handleStartPlay(timestamp.toMSecsSinceEpoch() , camera_id , channel_id);

}



/*
void PlaybackWidget::sendJson(int camerd_id, int channel_id, qint64 start_time, qint64 end_time)
{
    QJsonObject json;
    json.insert("camerd_id", camerd_id);
    json.insert("channel_id", channel_id);
    json.insert("start_time", start_time);
    json.insert("end_time", end_time);

    QJsonDocument doc(json);
    QByteArray byteArray = doc.toJson(QJsonDocument::Compact);
    QString jsonString = QString(byteArray);

    qDebug() << "json: " << jsonString;

}
*/

void PlaybackWidget::onSearchClicked()
{
    date = dateEdit->date();

 // 获取三个下拉框的当前值（转整数）

     int hour = startHourBox->currentText().toInt();
     int minute = startMinuteBox->currentText().toInt();
     int second = startSecondBox->currentText().toInt();

     // 创建开始时间对象
     QTime start_time(hour, minute, second);

     // 验证时间有效性
     if(start_time.isValid()) {
         qDebug() << "选中时间：" << start_time.toString("HH:mm:ss");
         // 输出示例：选中时间： "09:30:45"
     } else {
         qDebug() << "时间无效，请重新选择";
     }

     // 获取三个下拉框的当前值（转整数）
     hour = endHourBox->currentText().toInt();
     minute = endMinuteBox->currentText().toInt();
     second = endSecondBox->currentText().toInt();

     // 创建结束时间对象
     QTime end_time(hour, minute, second);

     // 验证时间有效性
     if(end_time.isValid()) {
         qDebug() << "选中时间：" << end_time.toString("HH:mm:ss");
         // 输出示例：选中时间： "09:30:45"
     } else {
         qDebug() << "时间无效，请重新选择";
     }

     // 验证时间范围有效性
     if (start_time >= end_time) {
         QMessageBox::warning(this, "错误", "结束时间必须晚于开始时间！");
         return;
     }


     QString device = deviceBox->currentText();
     if(device == nullptr){
         qDebug() << "device is nullptr";
     }else if(device == "摄像头1"){
         camera_id = 1;
     }else if(device == "摄像头2"){
         camera_id = 2;
     }


     QString channel = channelBox->currentText();
     if(channel == nullptr){
         qDebug() << "channel is nullptr";
     }else if(channel == "通道1"){
         channel_id = 0;
     }else if(channel == "通道2"){
         channel_id = 1;
     }
     //todo
     //此处通过窗口提供的4个信息，构建json
     QJsonObject json;
     json.insert("camera_id", camera_id);
     json.insert("channel", channel_id);
     json.insert("start_time", QDateTime(date,start_time).toMSecsSinceEpoch());
     json.insert("end_time", QDateTime(date,end_time).toMSecsSinceEpoch());

     QJsonDocument doc(json);
     QString jsonString = doc.toJson(QJsonDocument::Compact);

     qDebug() << "jsonString" << jsonString;



     _socket = new MyTcpSocket(this);
     _socket->connectToHost("192.168.105.108", 8000);

     connect(_socket, &MyTcpSocket::connected,[=](){
         _socket->sendTLV(TaskType::TASK_GET_PLAYBACK_RANGE, jsonString.length(), jsonString.toUtf8());
     });

     connect(_socket, &MyTcpSocket::readPacketFinished, this, &PlaybackWidget::handleGetTimeRange);


    isplay = true;
    playbackButtonGroup->Play(isplay);

//    // 显示列表
//    playbackList->show();
//    playbackList->showlist();
//    qDebug() << "显示回放列表";
}



void PlaybackWidget::handleGetTimeRange(Packet packet)
{
    //处理收到的事件信息的包
    //////////////
    if(packet._type == TASK_GET_PLAYBACK_RANGE_ERROR){
        //statusBar()->showMessage(tr("错误:获取历史记录失败"));
        return ;
    }
    //todo这个地方需要从服务器获得起始时间列表
    //从packet._msg解包出json,构建 QVector<QPair<int, int> >
    //

    QVector<QPair<int, int> > timeRanges;

    QJsonDocument jsonDoc = QJsonDocument::fromJson(packet._msg);

    qDebug() << QString::fromUtf8(packet._msg);

    qDebug() << "jsonDoc" << jsonDoc;

    QDateTime start(date);

    long last_time = start.toSecsSinceEpoch();

    qDebug() << "last_time" << last_time;

    if (!jsonDoc.isNull() && jsonDoc.isArray()) {
        QJsonArray deviceArray = jsonDoc.array();
        // 遍历设备列表
        for (const QJsonValue& value : deviceArray) {
            if (value.isObject()) {
                QJsonObject obj = value.toObject();

                qDebug() << obj ;

                qDebug() << obj["start_time"].toString();

                qDebug() << obj["start_time"].toString().toLongLong();

                qDebug() << obj["end_time"].toString().toLongLong();


                qlonglong start_time = obj["start_time"].toString().toLongLong()/1000;
                qlonglong end_time = obj["end_time"].toString().toLongLong()/1000;
                timeRanges.push_back(qMakePair(start_time / 1000 - last_time,end_time / 1000 - last_time));

                qDebug() << "start_time / 1000 - last_time" << start_time / 1000 - last_time;
                qDebug() << "end_time / 1000 - last_time" << end_time / 1000 - last_time;

                qDebug() << "start_time" << start_time << "end_time" << end_time;



            }
        }

    } else {
        qDebug() << "Failed to parse device list JSON or invalid format";
    }

    //设置上方绿条
    timerangewidget->addTimeRangeList(timeRanges);
}


void PlaybackWidget::onPlayPause()
{
    // todo
    //if(_currIdx >= 0){
        if(isplay == false) {
            //_vlcKits->play();
            isplay=true;
            qDebug() << "Play: isplay: true";
        } else{
            //_vlcKits->pause();
            isplay=false;
            qDebug() << "Pause: isplay: false";
        }

        playbackButtonGroup->Play(isplay);
    //}
}

void PlaybackWidget::on_btnStop_clicked()
{
    // todo
    qDebug() << "停止";
    //_vlcKits->stop();
    isplay=false;
    playbackButtonGroup->Play(isplay);
    playbackBottom->setCurPlayTime(0);
    playbackBottom->setTotalTime(0);
}

void PlaybackWidget::onSetPosition(int val)
{
    const int totalSecondsInDay = 86399; // 23:59:59
    double ratio = static_cast<double>(val) / 1000.0;
    int elapsedSeconds = static_cast<int>(ratio * totalSecondsInDay);

    int hours = elapsedSeconds / 3600;
    int minutes = (elapsedSeconds % 3600) / 60;
    int seconds = elapsedSeconds % 60;

    QTime time(hours, minutes, seconds);
    QString timeStr = time.toString("hh:mm:ss");
    qDebug() << "timeStr" << timeStr;

    QDateTime startDateTime(date, time);
    qDebug() << __LINE__ << "startDateTime" << startDateTime;
    QDateTime endDateTime(date, QTime(23, 59, 59));
    qDebug() << __LINE__ << "endDateTime" << endDateTime;

    qint64 startSec = startDateTime.toSecsSinceEpoch();
    qDebug() << __LINE__ << "startSec" << startSec;
    qint64 endSec = endDateTime.toSecsSinceEpoch();
    qDebug() << __LINE__ << "endSec" << endSec;

   //if(camerd_id != -1 && channel_id != -1 && startSec < endSec){
   //    sendJson(camerd_id, channel_id, startSec, endSec);
   //}
}


//void PlaybackWidget::playIdx(int idx)
//{
//    // todo
//    (void)idx;
//    if (isplay) {
//        //_vlcKits->stop();
//        isplay = false;
//    }

////    bool ret = _vlcKits->play(idx, (void*)_cVideoWidget->winId());

////    if (!ret) {
////        QMessageBox::warning(this, "错误", "无法播放文件");
////    }
////    if (ret) {
////        _isplay = true;
////    } else {
////        _isplay = false;
////    }

//    playbackButtonGroup->Play(isplay);
//}

//void PlaybackWidget::onPlaylistItemClicked()
//{
//    // todo
//    qDebug() << "双击列表项，播放当前项";
//}

//void PlaybackWidget::onPlayPre()
//{
//    // todo
//    qDebug() << "播放前一个";
//    if (isplay) {
//        //_vlcKits->stop();
//        isplay = false;
//    }

//    //bool ret = _vlcKits->play(idx, (void*)_cVideoWidget->winId());

//    //if (!ret) {
//    //    QMessageBox::warning(this, "错误", "无法播放文件");
//    //}
//    //if (ret) {
//    //    isplay = true;
//    //} else {
//    //    isplay = false;
//    //}

//    playbackButtonGroup->Play(isplay);
//}

//void PlaybackWidget::onPlayNext()
//{
//    // todo
//    qDebug() << "播放后一个";
////    int idx = -1;
////    if(_currIdx >= 0){
////        idx = _currIdx + 1;
////        idx %= _list->size();
////        playIdx(idx);
////    }else{
////        QMessageBox::warning(this, "错误", "当前没有视频");
////    }
//}

//void PlaybackWidget::onShowList()
//{
//    playbackList->setVisible(!playbackList->isVisible());
//}
